<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
<?php
session_cache_expire(10000);
ini_set('session.gc_maxlifetime', 10000 * 60);
@session_start();

error_reporting(0);
/**
 * set header no cache
 */
//header('Cache-control: private'); // IE 6 FIX
// always modified
//@header('Last-Modified: ' . gmdate("D, d M Y H:i:s") . ' GMT');
// HTTP/1.1
//@header('Cache-Control: no-store, no-cache, must-revalidate');
//@header('Cache-Control: post-check=0, pre-check=0', false);
// HTTP/1.0
//@header('Pragma: no-cache');

/**
 * set header with cache
 */
$seconds_to_cache = 2592000;//30 days
$ts = gmdate("D, d M Y H:i:s", time() + $seconds_to_cache) . " GMT";
header("Expires: $ts");
header("Pragma: cache");
header("Cache-Control: max-age=$seconds_to_cache");

include 'config.php';

$url = $_SERVER['REQUEST_URI'];
$url = preg_replace('/^\//', '', $url);

$aryURL = explode('/', $url);

//can sua lai $aryURL[0] khi tach
if (isset($aryURL[0])) {

    $controller = $aryURL[0];
}
//can sua lai $aryURL[1] khi tach
if (isset($aryURL[1])) {
    $adminController = $aryURL[1];
}

//$controller = 'admin';
if (get_magic_quotes_gpc()) {

    function stripslashes_deep($value) {
        
        $value = is_array($value) ? array_map('stripslashes_deep', $value) : stripslashes($value);

        return $value;
    }

    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
    $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
}
//CONTROLLER
if ($controller && $controller == 'quanly') {
    include adminController_class;
    $objAdmin = new AdminControllers($aryConfigDB, $aryConfigs);
    $objAdmin->setParamsByUrl($aryURL);
    if ($adminController == false) {
        $objAdmin->def();
    } else {
        $objAdmin->$adminController();
    }
} else {
    include myController_class;
    $objController = new MyControllers($aryConfigDB, $aryConfigs);
    $objController->setParamsByUrl($aryURL);
    if ($controller == false) {
        $objController->def();
    } else {
        $objController->$controller();
    }
}
?>
